import { observable, action, makeObservable } from "mobx";
import { PageDateSelect } from '@/types/pages/enum'
import { ChangeButton, FnCallBack } from '@/types/header/types'

/**
 * interface HeaderScreen
 * 头部公共类型规范
 */
export interface HeaderScreen<T> {
    currentPageType?: PageDateSelect
    screenData?: T;
    changeButton?: ChangeButton<T>;
    fnCallBack?: FnCallBack;
}

export interface HeaderType{
    headerName:string;
    headerControl:HeaderScreen<any>;
}

/**
 * class Header
 * 头部公共状态
 */
class Header {
    @observable headerName: string = ""
    @observable currentPageType: PageDateSelect = PageDateSelect.year
    @observable headerControl: HeaderScreen<any> = { currentPageType: PageDateSelect.year, screenData: {} }

    constructor() {
        makeObservable(this)
    }
   /**
     * 
     * @param type 日期选择函数
     * @param date 传入日期
     */
    @action initHeaderControl<T>(type: PageDateSelect,
        changeButton: ChangeButton<T>,
        fnCallBack: FnCallBack) {
        this.headerControl = { currentPageType: type, changeButton, fnCallBack }
    }
    /**
     * 
     * @param type 日期选择类型
     */
    @action setCurrentPageType<T>(type: PageDateSelect) {
        this.headerControl.currentPageType = type;
    }
    /**
     * 
     * @param data 对应大屏的填充数据
     */
    @action srtScreenData<T>(data: T) {
        this.headerControl.screenData = data;
    }
    /**
     * 
     * @param hange 点击时间按钮函数绑定
     */
    @action setChangeButton<T>(hange: ChangeButton<T>) {
        this.headerControl.changeButton = hange;
    }
    /**
     * 
     * @param hange 回调绑定
     */
    @action setFnCallBack<T>(hange: FnCallBack) {
        this.headerControl.fnCallBack = hange;
    }

    /**
     * 
     * @param str 回调绑定
     */
    @action setHeaderName(str: string) {
        this.headerName = str;
    }
}

export default Header;